-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix(vscode): filter out non-file doc uri in stage change hook #314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Warning Rate limit exceeded@ymc9 has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 39 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (1)
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughUpdates the VSCode extension version and refactors the language module to process Parsed-phase documents individually with lexer/parser and URI guards, per-document plugin document loading, and early returns on errors. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–30 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @ymc9's task —— View job PR Review for "fix(vscode): filter out non-file doc uri in stage change hook"Todo List:
Review SummaryThis PR makes two main changes:
Detailed Analysis🔧 Code Quality & Best Practices - ✅ GoodPositive aspects:
Minor suggestions:
🐛 Potential Bugs & Issues - ✅ FixedThe main fix addresses a real issue: // Before: No filtering - could process non-file URIs
shared.workspace.DocumentBuilder.onBuildPhase(DocumentState.Parsed, async (documents) => {
for (const doc of documents) {
// Direct processing without URI scheme check
const schemaPath = fileURLToPath(doc.uri.toString());After: Proper filtering: // After: Filters out non-file URIs
shared.workspace.DocumentBuilder.onDocumentPhase(DocumentState.Parsed, async (doc) => {
if (doc.uri.scheme !== 'file') {
return; // Skip non-file documents
}
const schemaPath = fileURLToPath(doc.uri.toString());Why this matters:
⚡ Performance Considerations - ✅ ImprovedPositive changes:
🔒 Security Concerns - ✅ SafeSecurity aspects:
🧪 Test Coverage -
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Fixes the stage-change handling by ignoring non-file documents and aligning to per-document phase callbacks.
- Switch from batch build-phase hook to per-document phase hook
- Guard against non-file URIs to prevent fileURLToPath errors
- Bump VS Code extension version
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/language/src/module.ts | Replace onBuildPhase with onDocumentPhase; add early returns for parse errors and non-file URIs before path conversion. |
| packages/ide/vscode/package.json | Bump extension version to 3.0.11 to publish the fix. |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/language/src/module.ts (1)
107-119: Plugin loading logic correctly implemented.The per-document approach with
getOrCreateDocumentshould handle caching to avoid redundant plugin loads. The logic correctly:
- Resolves the file path from the validated file URI
- Retrieves plugin schemas for the current document
- Loads and indexes each plugin model
Consider wrapping the plugin loading loop in a try-catch for robustness, though the framework may already provide error boundaries:
const schemaPath = fileURLToPath(doc.uri.toString()); const pluginSchemas = getPluginDocuments(doc.parseResult.value as Model, schemaPath); +try { for (const plugin of pluginSchemas) { // load the plugin model document const pluginDoc = await shared.workspace.LangiumDocuments.getOrCreateDocument( URI.file(path.resolve(plugin)), ); // add to indexer so the plugin model's definitions are globally visible shared.workspace.IndexManager.updateContent(pluginDoc); if (logToConsole) { console.log(`Loaded plugin model: ${plugin}`); } } +} catch (error) { + // Log but don't fail document processing if plugin loading fails + if (logToConsole) { + console.error(`Failed to load plugin models:`, error); + } +}
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
packages/ide/vscode/package.json(1 hunks)packages/language/src/module.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/ide/vscode/package.jsonpackages/language/src/module.ts
packages/ide/vscode/package.json
📄 CodeRabbit inference engine (CLAUDE.md)
The
ide/vscodepackage is intentionally versioned differently from other packages
Files:
packages/ide/vscode/package.json
🧠 Learnings (1)
📚 Learning: 2025-09-04T12:38:14.150Z
Learnt from: CR
PR: zenstackhq/zenstack-v3#0
File: CLAUDE.md:0-0
Timestamp: 2025-09-04T12:38:14.150Z
Learning: Applies to packages/ide/vscode/package.json : The `ide/vscode` package is intentionally versioned differently from other packages
Applied to files:
packages/ide/vscode/package.json
🧬 Code graph analysis (1)
packages/language/src/module.ts (2)
packages/language/src/utils.ts (1)
getPluginDocuments(579-637)packages/language/src/generated/ast.ts (2)
Model(559-563)Model(565-565)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: claude-review
🔇 Additional comments (3)
packages/ide/vscode/package.json (1)
4-4: LGTM! Version bump aligns with language module changes.The version increment from 3.0.9 to 3.0.11 is appropriate for this extension release that accompanies the per-document processing refactor in the language module.
packages/language/src/module.ts (2)
97-101: Good defensive guard against processing invalid documents.The early return when lexer or parser errors are present prevents processing documents with incomplete ASTs, which could lead to downstream errors during plugin inspection.
103-105: Correct fix for the reported issue.This guard appropriately filters out non-file URIs (e.g.,
untitled:,vscode:) before attempting file system operations. This prevents errors when processing in-memory or virtual documents that don't have physical file paths.
|
Claude finished @ymc9's task —— View job PR Review for "fix(vscode): filter out non-file doc uri in stage change hook" Todo List:
Review SummaryThis PR makes two main changes:
Detailed Analysis🔧 Code Quality & Best Practices - ✅ GoodPositive aspects:
Minor suggestions:
🐛 Potential Bugs & Issues - ✅ FixedThe main fix addresses a real issue: // Before: No filtering - could process non-file URIs
shared.workspace.DocumentBuilder.onBuildPhase(DocumentState.Parsed, async (documents) => {
for (const doc of documents) {
// Direct processing without URI scheme check
const schemaPath = fileURLToPath(doc.uri.toString());After: Proper filtering: // After: Filters out non-file URIs
shared.workspace.DocumentBuilder.onBuildPhase(DocumentState.Parsed, async (documents) => {
for (const doc of documents) {
if (doc.parseResult.lexerErrors.length > 0 || doc.parseResult.parserErrors.length > 0) {
return; // Early exit on parse errors
}
if (doc.uri.scheme !== 'file') {
return; // Skip non-file documents
}
const schemaPath = fileURLToPath(doc.uri.toString());Why this matters:
⚡ Performance Considerations - ✅ ImprovedPositive changes:
Potential concern: The 🔒 Security Concerns - ✅ SafeSecurity aspects:
🧪 Test Coverage -
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 3
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/language/src/module.ts(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/language/src/module.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: claude-review
|
Claude finished @ymc9's task —— View job PR Review for "fix(vscode): filter out non-file doc uri in stage change hook"Todo List:
Review SummaryThis PR makes two main changes:
Detailed Analysis🔧 Code Quality & Best Practices - ✅ GoodPositive aspects:
Minor issue:
🐛 Potential Issues Analysis - ✅ Implementation is CorrectThe current implementation is actually correct: // Line 103 - CORRECT: skips current document in batch processing
if (doc.parseResult.lexerErrors.length > 0 || doc.parseResult.parserErrors.length > 0) {
continue; // Skips this document, processes remaining documents
}
// Line 107 - CORRECT: filters out non-file URIs
if (doc.uri.scheme !== 'file') {
continue; // Skips non-file documents, continues with file documents
}Why this is correct:
Root cause addressed:
⚡ Performance Considerations - ✅ ImprovedPositive changes:
🔒 Security Concerns - ✅ SafeSecurity aspects:
🧪 Test Coverage -
|
|
Claude finished @ymc9's task —— View job PR Review: "fix(vscode): filter out non-file doc uri in stage change hook"Todo List:
Review SummaryThis PR makes two main changes:
Detailed Analysis🔧 Code Quality & Best Practices - ✅ GoodPositive aspects:
Recent improvements based on reviewer feedback:
🐛 Potential Bugs & Issues - ✅ FixedThe main fix addresses a real issue: // Before: No filtering - could process non-file URIs
const schemaPath = fileURLToPath(doc.uri.toString()); // Would throw for non-file URIs
// After: Proper filtering
if (doc.uri.scheme !== 'file') {
continue; // Skip non-file documents
}
const schemaPath = fileURLToPath(doc.uri.toString()); // Safe to call nowWhy this matters:
⚡ Performance Considerations - ✅ ImprovedPositive changes:
🔒 Security Concerns - ✅ SafeSecurity aspects:
🧪 Test Coverage -
|
Summary by CodeRabbit
Updates
Bug Fixes